import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace TechnicianSkillApi {
  /** SPA技师技能信息 */
  export interface TechnicianSkill {
    id: number; // 主键ID
    technicianId?: number; // 技师ID
    skillName?: string; // 技能名称
    skillLevel: string; // 技能等级
    skillScore: number; // 技能评分
    certificationDate: string | Dayjs; // 认证日期
    validityPeriod: number; // 有效期(天)
    skillDescription: string; // 技能描述
    scope: string; // 权限范围
    scoperef: string; // 权限引用
  }
}

/** 查询SPA技师技能分页 */
export function getTechnicianSkillPage(params: PageParam) {
  return requestClient.get<PageResult<TechnicianSkillApi.TechnicianSkill>>(
    '/spa/technician-skill/page',
    { params },
  );
}

/** 查询SPA技师技能详情 */
export function getTechnicianSkill(id: number) {
  return requestClient.get<TechnicianSkillApi.TechnicianSkill>(
    `/spa/technician-skill/get?id=${id}`,
  );
}

/** 新增SPA技师技能 */
export function createTechnicianSkill(
  data: TechnicianSkillApi.TechnicianSkill,
) {
  return requestClient.post('/spa/technician-skill/create', data);
}

/** 修改SPA技师技能 */
export function updateTechnicianSkill(
  data: TechnicianSkillApi.TechnicianSkill,
) {
  return requestClient.put('/spa/technician-skill/update', data);
}

/** 删除SPA技师技能 */
export function deleteTechnicianSkill(id: number) {
  return requestClient.delete(`/spa/technician-skill/delete?id=${id}`);
}

/** 导出SPA技师技能 */
export function exportTechnicianSkill(params: any) {
  return requestClient.download('/spa/technician-skill/export-excel', {
    params,
  });
}
